"""
员工管理，接口对象层 封装
"""
import requests


class EmpApi(object):
    # 添加员工的 接口
    @classmethod
    def add_emp(cls, header, json_data):
        url = "http://ihrm-test.itheima.net/api/sys/user"
        resp = requests.post(url=url, headers=header, json=json_data)
        return resp

    # 查询员工 接口
    @classmethod
    def query_emp(cls, user_id, header):
        # url = "http://ihrm-test.itheima.net/api/sys/user/{}".format(user_id)
        url = "http://ihrm-test.itheima.net/api/sys/user/" + user_id
        resp = requests.get(url=url, headers=header)
        return resp

    # 修改员工 接口
    @classmethod
    def modify_emp(cls, user_id, header, json_data):
        url = "http://ihrm-test.itheima.net/api/sys/user/{}".format(user_id)
        resp = requests.put(url=url, headers=header, json=json_data)
        return resp

    # 删除员工 接口
    @classmethod
    def delete_emp(cls, user_id, header):
        url = "http://ihrm-test.itheima.net/api/sys/user/{}".format(user_id)
        resp = requests.delete(url=url, headers=header)
        return resp
